package com.fenghuajueli.libbasecoreui.utils;

import com.tencent.mmkv.MMKV;

/**
 * 腾讯mmkv框架 替代系统的sharedPreferences
 */
public class MmkvUtils {

    public static MMKV mmkv = MMKV.defaultMMKV();

    public static void save(String key, String data) {
        mmkv.encode(key, data);
    }

    public static void save(String key, int data) {
        mmkv.encode(key, data);
    }

    public static void save(String key, long data) {
        mmkv.encode(key, data);
    }

    public static void save(String key, boolean data) {
        mmkv.encode(key, data);
    }

    public static void save(String key, double data) {
        mmkv.encode(key, data);
    }

    public static void save(String key, float data) {
        mmkv.encode(key, data);
    }


    public static String get(String key, String defaultValue) {
        return mmkv.decodeString(key, defaultValue);
    }

    public static int get(String key, int defaultValue) {
        return mmkv.decodeInt(key, defaultValue);
    }

    public static long get(String key, long defaultValue) {
        return mmkv.decodeLong(key, defaultValue);
    }

    public static boolean get(String key, boolean defaultValue) {
        return mmkv.decodeBool(key, defaultValue);
    }

    public static double get(String key, double defaultValue) {
        return mmkv.decodeDouble(key, defaultValue);
    }

    public static float get(String key, float defaultValue) {
        return mmkv.decodeFloat(key, defaultValue);
    }

}
